const path = require('path');
var rootDir = path.resolve(__dirname);
// function DtsBundlePlugin() {}
// DtsBundlePlugin.prototype.apply = function (compiler) {
//     compiler.plugin('done', function () {
//         var dts = require('dts-bundle');

//         dts.bundle({
//             name: 'your-lib-name',
//             main: rootDir + '/src/types/*.d.ts',
//             out: rootDir + '/dist/main.d.ts',
//             removeSource: true,
//             outputAsModuleFolder: true 
//         });
//     });
// };

// const DtsPlugin = require('dts-webpack-plugin');
// import DtsBundlePlugin from 'webpack-dts-bundle';

module.exports = {
    mode: 'development',
    entry: './src/main.ts',
    devtool:'source-map',
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [           
            {
                enforce: 'pre',
                test: /\.js$/,
                use: "source-map-loader"
            },
            {
                enforce: 'pre',
                test: /\.ts?$/,
                use: "source-map-loader"
            },
            {
                // For our normal typescript
                test: /\.ts?$/,
                use: [
                    {
                        loader: 'ts-loader'
                    }
                ],
                exclude: /(?:node_modules)/,
            },
        ]
    },
    resolve: {
        modules: [
            'src',
            'node_modules'
        ],
        extensions: [
            '.js',
            '.ts'
        ]
    },
    devServer: {
        hot: true,
        compress: true,
        host: 'localhost',
        port: 8888
      } 
};